package org.birrap.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "CERVEZAS_T")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CervezasT.findAll", query = "SELECT c FROM CervezasT c"),
    @NamedQuery(name = "CervezasT.findByIdCerveza", query = "SELECT c FROM CervezasT c WHERE c.idCerveza = :idCerveza"),
    @NamedQuery(name = "CervezasT.findByMarca", query = "SELECT c FROM CervezasT c WHERE c.marca = :marca"),
    @NamedQuery(name = "CervezasT.findByTipo", query = "SELECT c FROM CervezasT c WHERE c.tipo = :tipo"),
    @NamedQuery(name = "CervezasT.removeByIdCerveza",query = "DELETE FROM CervezasT c WHERE c.idCerveza = :idCerveza")})
@SequenceGenerator (name="SEQ_CERVEZAS_T" , sequenceName ="SEQ_CERVEZAS_T" , allocationSize = 1)

public class CervezasT implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_CERVEZA")
    @GeneratedValue (strategy = GenerationType.SEQUENCE, generator = "SEQ_CERVEZAS_T")
    private Integer idCerveza;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "MARCA")
    private String marca;
    @Size(max = 20)
    @Column(name = "TIPO")
    private String tipo;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cervezasT")
    private Collection<BaresCervezasTapasVasosT> baresCervezasTapasVasosTCollection;

    public CervezasT() {
    }

    public CervezasT(Integer idCerveza) {
        this.idCerveza = idCerveza;
    }

    public CervezasT(Integer idCerveza, String marca) {
        this.idCerveza = idCerveza;
        this.marca = marca;
    }

    public Integer getIdCerveza() {
        return idCerveza;
    }

    public void setIdCerveza(Integer idCerveza) {
        this.idCerveza = idCerveza;
    }

    public String getMarca() {
        return marca;
    }

    public void setMarca(String marca) {
        this.marca = marca;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    @XmlTransient
    public Collection<BaresCervezasTapasVasosT> getBaresCervezasTapasVasosTCollection() {
        return baresCervezasTapasVasosTCollection;
    }

    public void setBaresCervezasTapasVasosTCollection(Collection<BaresCervezasTapasVasosT> baresCervezasTapasVasosTCollection) {
        this.baresCervezasTapasVasosTCollection = baresCervezasTapasVasosTCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCerveza != null ? idCerveza.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CervezasT)) {
            return false;
        }
        CervezasT other = (CervezasT) object;
        if ((this.idCerveza == null && other.idCerveza != null) || (this.idCerveza != null && !this.idCerveza.equals(other.idCerveza))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.birrap.ejb.CervezasT[ idCerveza=" + idCerveza + " ]";
    }
    
}
